package com.tiantianfresh.admin.service.Impl;

import com.tiantianfresh.admin.service.CommodityService;
import com.tiantianfresh.model.dao.CommodityMapper;
import com.tiantianfresh.model.pojo.Commodity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommodityServiceImpl implements CommodityService {
    @Resource
    private CommodityMapper commodityMapper;
    @Override
    //查询全部
    public List<Commodity> selectAll(Integer crid) {
        return commodityMapper.queryCommodityCatid(crid);
    }
    //根据id查询
    @Override
    public Commodity queryCommodityById(int id) {
        return commodityMapper.queryCommodityById(id);
    }
    //根据id删除
    @Override
    public boolean deleteCommodityById(int id) {
        if(commodityMapper.deleteCommodityById(id)>0) return true;
        return false;
    }

    @Override
    public boolean addCommodity(Commodity commodity) {
        if (commodityMapper.addCommodity(commodity)>0) return true;
        return false;
    }

    @Override
    public boolean updateCommodity(Commodity commodity) {
        if (commodityMapper.updateCommodity(commodity)>0) return true;
        return false;
    }
}
